/*
  Copyright 2011 fullkawa

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package jp.fullkawa.xnovel.picture;

import jp.fullkawa.xnovel.Carriable;
import jp.fullkawa.xnovel.Layerable;

/**
 * 背景等の画像
 * 瞬時に表示される
 * @author fullkawa
 */
public class Image extends Picture implements Carriable, Layerable
{
	private String layerId;
	private String caption;

	public Image() {}

	public Image(String src)
	{
		this();
		this.setSrc(src);
		this.setChange(true);
	}

	public String getLayerId() {
		return layerId;
	}
	public void setLayerId(String layerId) {
		this.layerId = layerId;
	}
	public String getCaption() {
		return caption;
	}
	public void setCaption(String caption) {
		this.caption = caption;
	}

	@Override
	public String getTag()
	{
		if (this.isChange() == false)
		{
			return null;
		}
		StringBuilder tag = new StringBuilder();

		tag.append("<img id=\"");
		if (this.getLayerId() != null) tag.append(this.getLayerId());
		tag.append("\" src=\"");
		if (this.getSrc() != null) tag.append(this.getSrc());
		tag.append("\" />");

		return tag.toString();
	}
}
